package com.tools.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Author LGJ
 * @create 2023/1/13 16:19
 * @Description spring工具类
 */
public class StringUtils {

    /**
     * 去除前后空格，判断字符串==null或长度为0
     * @param str
     * @return
     */
    public static boolean isEmptyString(String str) {
        return (str == null) || (str.trim().length() == 0);
    }

    /**
     * 判断字符串==null或长度为0
     * @param str
     * @return
     */
    public static boolean isNullOrEmpty(String str) {
        return str == null || str.length() == 0;
    }

    /**
     * 判断非空
     * @param str
     * @return
     */
    public static boolean isNotEmpty(String str) {
        return !isEmpty(str);
    }

    /**
     * 判断是否为空
     * @param str
     * @return
     */
    public static boolean isEmpty(String str) {
        return "null".equals(str) || str == null || "".equals(str);
    }

    /**
     * 判断是否为手机号码 符合返回ture
     * @param str
     * @return boolean
     */
    public static boolean isMobile(String str) {
        if (null == str || str.trim().length() <= 0) {
            return false;
        }
        String pattern = "^1\\d{10}$";
        Pattern p = Pattern.compile(pattern);
        Matcher m = p.matcher(str);
        return m.matches();
    }

    public static void main(String[] args) {
        System.out.println(isMobile("1123456789"));
    }

}
